package com.hanamaki.homework;

/**
 * @author hanamaki
 * @version 1.0
 * @date 2021/7/6 15:59
 */
public class Triangle {

    private int a;
    private int b;
    private int c;

    /**
     * 判断三角形是否成立
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    public boolean isTriangle(int a, int b, int c) {
        if (a + b > c && a + c > b && b + c > a) {
            this.a = a;
            this.b = b;
            this.c = c;
            return true;
        } else {
            return false;
        }
    }

    /**
     * 计算三角型的周长
     *
     * @return
     */
    public double perimeter() {

        return a + b + c;

    }

    /**
     * 三角形的面积
     *
     * @return
     */
    public double area() {
        /*使用 海伦公式*/
        double p = (a + b + c) / 2;
        double areas = Math.sqrt(p * (p - this.a) * (p - this.b) * (p - this.c));
        return areas;
    }


}
